home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / goodies / chromakeymovie / doevent.c < prev    next >
Encoding:
Text File  |  2000-06-23  |  4.2 KB  |  199 lines

  1. /*
  2.     File:        doevent.c
  3.  
  4.     Contains:    
  5.  
  6.     Written by: Jason Hodges-Harris        
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/28/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25.  
  26.  
  27. // Mac toolbox headers
  28.  
  29. #ifndef __DESK__
  30. #include <Desk.h>
  31. #endif
  32.  
  33. #ifndef __DISKINIT__
  34. #include <DiskInit.h>
  35. #endif
  36.  
  37. #ifndef __EVENTS__
  38. #include <Events.h>
  39. #endif
  40.  
  41. #ifndef __MENUS__
  42. #include <Menus.h>
  43. #endif
  44.  
  45. #ifndef __MOVIES__
  46. #include <Movies.h>
  47. #endif
  48.  
  49. #ifndef __QDOFFSCREEN__
  50. #include <QDOffscreen.h>
  51. #endif
  52.  
  53. #ifndef __TOOLUTILS__
  54. #include <ToolUtils.h>
  55. #endif
  56.  
  57. #ifndef __WINDOWS__
  58. #include <Windows.h>
  59. #endif
  60.  
  61.  
  62. // Program headers
  63.  
  64. #ifndef __CHROMAPPHEADER__
  65. #include "ChromaKeyMovie.h"
  66. #endif
  67. //    Global Variables
  68.  
  69. extern short            gKeyMode;
  70. extern Boolean            gMovieOpen;
  71.  
  72.  
  73. // DoEvent function processess the events posted by the application.
  74. // This includes the handling of the movie controller, mouse, key,
  75. // disk and operating system events.
  76.  
  77. #pragma segment Main
  78. void DoEvent (EventRecord *eventPtr)
  79. {
  80.     WindowPtr        theWindow,
  81.                     theTempWindow;
  82.     char            theChar;
  83.     
  84.     theWindow = FrontWindow();
  85.     theTempWindow = theWindow;
  86.     if (gMovieOpen)
  87.     {
  88.         while (theTempWindow != nil)
  89.         {
  90.             MCIsPlayerEvent((**((MovieDocHndl)
  91.                 GetWRefCon(theTempWindow))).theController,eventPtr);
  92.             theTempWindow = &(*(((WindowPeek)theTempWindow)->nextWindow)).port;
  93.         }
  94.     }
  95.     switch (eventPtr->what)
  96.     {
  97.         case nullEvent:
  98.             if (gMovieOpen)
  99.             {
  100.                 switch (gKeyMode)
  101.                 {
  102.                     case transparentMode:
  103.                         TransparentKeyMode(theWindow);    // use transparent transfer mode
  104.                     break;
  105.                     case graphix:
  106.                     break;
  107.                     case modifierTrax:
  108.                     break;
  109.                 }
  110.             }
  111.         break;
  112.         case mouseDown:
  113.             HandleMouseDown(eventPtr);
  114.         break;
  115.         case mouseUp:
  116.         break;
  117.         case keyDown:
  118.         case autoKey:
  119.             theChar=eventPtr->message & charCodeMask;
  120.             if ((eventPtr->modifiers &cmdKey) !=0)
  121.                 DoMenuCommand(MenuKey (theChar));
  122.         break;
  123.         case keyUp:
  124.         break;
  125.         case updateEvt:
  126.             DoWindUpdate((WindowPtr)(eventPtr->message));
  127.         break;
  128.         case diskEvt:
  129.             DoDiskEvt(eventPtr);    // disk inserted event
  130.         break;
  131.         case osEvt:
  132.             if (eventPtr->message>>24==resumeFlag)
  133.             //Show_Cursor(ARROW_CURSOR); // reset cursor
  134.                 SetCursor(&qd.arrow);
  135.         break;
  136.     }
  137. }
  138.  
  139.  
  140. // HandleMouseDown controls the further processing of mouse button down events.
  141. // This includes testing the location of the mouse pointer at the time of the event
  142. // and performing the appropriate action. e.g. if the mouse button was pressed
  143. // whilst the pointer was in the menubar, the value returned by MenuSelect()
  144. // (used to determine which menubar and item selected) is passed into DoMenuCommand()
  145. // which in turn handles the processing of the selected menu items.
  146.  
  147. #pragma segment Main
  148. void HandleMouseDown(EventRecord *eventPtr)
  149. {
  150.     WindowPtr    window;
  151.     short        thePart;
  152.     long        menuChoice;
  153.     
  154.     thePart=FindWindow (eventPtr->where,&window);
  155.     switch (thePart)
  156.     {
  157.         case inMenuBar:
  158.             menuChoice = MenuSelect (eventPtr->where);
  159.             DoMenuCommand(menuChoice);
  160.             break;
  161.         case inSysWindow:
  162.             SystemClick(eventPtr,window);
  163.             break;
  164.         case inDrag:
  165.             DragSelWind(window,eventPtr->where);
  166.         case inGoAway:
  167.             DoGoAwayWind(window,eventPtr->where);
  168.         break;
  169.         case inContent:
  170.             {
  171.                 if(window!=FrontWindow())
  172.                 {
  173.                     SelectWindow(window);
  174.                     break;
  175.                 }
  176.             }
  177.         break;
  178.         case osEvt:
  179.         break;
  180.     }
  181. }
  182.  
  183.  
  184. // DoDiskEvt handles the event post by the OS when a disk is insert
  185. // and displays an error is the media cannot be mounted.
  186.  
  187. #pragma segment Main
  188. void DoDiskEvt(EventRecord *eventPtr)
  189. {
  190.     short    ErrResult;
  191.     Point    ErrPoint;
  192.  
  193.     if((HiWord(eventPtr->message)!=noErr))
  194.     {
  195.         SetPt(&ErrPoint,100,100);
  196.         ErrResult=DIBadMount(ErrPoint,eventPtr->message);
  197.     }
  198. }
  199.